package com.cloudsigns.factorymanager2.produce.bean;

import android.text.TextUtils;
import android.util.Log;

import com.cloudsigns.factorymanager2.cusenum.CommonEnum;
import com.cloudsigns.factorymanager2.produce.utils.FormatTime;
import com.cloudsigns.factorymanager2.produce.utils.ParseJson;
import com.cloudsigns.factorymanager2.project.utils.DateUtil;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import static com.bumptech.glide.gifdecoder.GifHeaderParser.TAG;

public class WorkPartDailyFeedbackBean implements Serializable {
    private String accountId;// 反馈人账号ID
    private String accountName;// 反馈人账号名称
    private int applyAmount;// 申请数量
    private int applyDays;// 申请天数
    private int completeCount;// 本次反馈完成数量
    private String completeUnusualAccountId;// 班组：异常回复账号ID
    private String completeUnusualAccountName;// 班组：异常回复账号名称
    private long completeUnusualDate;//	班组：异常回复时间
    private String completeUnusualDesc;// 班组：异常回复内容说明
    private String confirmCompleteUnusualAccountId;// 管理员：确认-异常回复账号ID
    private String confirmCompleteUnusualAccountName;//	管理员：确认-异常回复账号名称
    private long confirmCompleteUnusualDate;// 管理员：确认-异常回复时间
    private long feedbackDate;// 反馈时间
    private String feedbackInfo;// 反馈说明
    private CommonEnum.FeedbackStatus feedbackStatus;// 异常反馈状态: 等待异常确认；等待异常回复；等待异常回复确认；异常回复已确认	必须为以下可用值之一: [ "WAIT_CONFIRM", "CONFIRM_FINISH", "WAIT_REPLY_CONFIRM", "REPLY_CONFIRM_FINISH" ]
    private long handleDate;// 确认时间
    private String handleInfo;// 确认内容说明
    private String handlerAccountId;// 确认人账号ID
    private String handlerAccountName;// 确认人账号名称
    private List<String> imgUrlList = new ArrayList<>(); // 反馈上传图片
    private CommonEnum.WorkPartSubType subType;// 异常反馈子类型：计划异常，生产异常 必须为以下可用值之一: [ "PLAN_UNUSUAL", "PRODUCE_UNUSUAL" ]
    private CommonEnum.WorkPartType type;//	反馈类型：正常、异常、申请调整、申请返工、申请报废  必须为以下可用值之一: [ "NORMAL", "UNUSUAL", "APPLY_ADJUST", "APPLY_RETURN", "APPLY_SCRAP" ]
    private String unusualAdvice;//	异常反馈建议
    private int unusualDays;// 异常影响天数
    private String unusualInfo;// 异常反馈原因说明
    private String workPartFeedbackId;// 反馈id
    /*自定义的*/
    private boolean noFeedBack;

    /*上级id*/
    private String orderId;// 订单id
    private String productId;// 产品id
    private String workPartId;// 工序id
    private String workPartOrderId;// 工序分派单id

    public void setParnetId(String orderId, String productId, String workPartId, String workPartOrderId) {
        this.orderId = orderId;
        this.productId = productId;
        this.workPartId = workPartId;
        this.workPartOrderId = workPartOrderId;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public int getApplyAmount() {
        return applyAmount;
    }

    public void setApplyAmount(int applyAmount) {
        this.applyAmount = applyAmount;
    }

    public int getApplyDays() {
        return applyDays;
    }

    public void setApplyDays(int applyDays) {
        this.applyDays = applyDays;
    }

    public int getCompleteCount() {
        return completeCount;
    }

    public void setCompleteCount(int completeCount) {
        this.completeCount = completeCount;
    }

    public String getCompleteUnusualAccountId() {
        return completeUnusualAccountId;
    }

    public void setCompleteUnusualAccountId(String completeUnusualAccountId) {
        this.completeUnusualAccountId = completeUnusualAccountId;
    }

    public String getCompleteUnusualAccountName() {
        return completeUnusualAccountName;
    }

    public void setCompleteUnusualAccountName(String completeUnusualAccountName) {
        this.completeUnusualAccountName = completeUnusualAccountName;
    }

    public long getCompleteUnusualDate() {
        return completeUnusualDate;
    }

    public void setCompleteUnusualDate(long completeUnusualDate) {
        this.completeUnusualDate = completeUnusualDate;
    }

    public String getCompleteUnusualDesc() {
        return completeUnusualDesc;
    }

    public void setCompleteUnusualDesc(String completeUnusualDesc) {
        this.completeUnusualDesc = completeUnusualDesc;
    }

    public String getConfirmCompleteUnusualAccountId() {
        return confirmCompleteUnusualAccountId;
    }

    public void setConfirmCompleteUnusualAccountId(String confirmCompleteUnusualAccountId) {
        this.confirmCompleteUnusualAccountId = confirmCompleteUnusualAccountId;
    }

    public String getConfirmCompleteUnusualAccountName() {
        return confirmCompleteUnusualAccountName;
    }

    public void setConfirmCompleteUnusualAccountName(String confirmCompleteUnusualAccountName) {
        this.confirmCompleteUnusualAccountName = confirmCompleteUnusualAccountName;
    }

    public long getConfirmCompleteUnusualDate() {
        return confirmCompleteUnusualDate;
    }

    public void setConfirmCompleteUnusualDate(long confirmCompleteUnusualDate) {
        this.confirmCompleteUnusualDate = confirmCompleteUnusualDate;
    }

    public long getFeedbackDate() {
        return feedbackDate;
    }

    public void setFeedbackDate(long feedbackDate) {
        this.feedbackDate = feedbackDate;
    }

    public String getFeedbackInfo() {
        return feedbackInfo;
    }

    public void setFeedbackInfo(String feedbackInfo) {
        this.feedbackInfo = feedbackInfo;
    }

    public CommonEnum.FeedbackStatus getFeedbackStatus() {
        return feedbackStatus;
    }

    public void setFeedbackStatus(CommonEnum.FeedbackStatus feedbackStatus) {
        this.feedbackStatus = feedbackStatus;
    }

    public long getHandleDate() {
        return handleDate;
    }

    public void setHandleDate(long handleDate) {
        this.handleDate = handleDate;
    }

    public String getHandleInfo() {
        return handleInfo;
    }

    public void setHandleInfo(String handleInfo) {
        this.handleInfo = handleInfo;
    }

    public String getHandlerAccountId() {
        return handlerAccountId;
    }

    public void setHandlerAccountId(String handlerAccountId) {
        this.handlerAccountId = handlerAccountId;
    }

    public String getHandlerAccountName() {
        return handlerAccountName;
    }

    public void setHandlerAccountName(String handlerAccountName) {
        this.handlerAccountName = handlerAccountName;
    }

    public List<String> getImgUrlList() {
        return imgUrlList;
    }

    public void setImgUrlList(List<String> imgUrlList) {
        this.imgUrlList = imgUrlList;
    }

    public CommonEnum.WorkPartSubType getSubType() {
        return subType;
    }

    public void setSubType(CommonEnum.WorkPartSubType subType) {
        this.subType = subType;
    }

    public CommonEnum.WorkPartType getType() {
        return type;
    }

    public void setType(CommonEnum.WorkPartType type) {
        this.type = type;
    }

    public String getUnusualAdvice() {
        return unusualAdvice;
    }

    public void setUnusualAdvice(String unusualAdvice) {
        this.unusualAdvice = unusualAdvice;
    }

    public int getUnusualDays() {
        return unusualDays;
    }

    public void setUnusualDays(int unusualDays) {
        this.unusualDays = unusualDays;
    }

    public String getUnusualInfo() {
        return unusualInfo;
    }

    public void setUnusualInfo(String unusualInfo) {
        this.unusualInfo = unusualInfo;
    }

    public String getWorkPartFeedbackId() {
        return workPartFeedbackId;
    }

    public void setWorkPartFeedbackId(String workPartFeedbackId) {
        this.workPartFeedbackId = workPartFeedbackId;
    }

    public boolean isNoFeedBack() {
        return noFeedBack;
    }

    public void setNoFeedBack(boolean noFeedBack) {
        this.noFeedBack = noFeedBack;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public String getWorkPartId() {
        return workPartId;
    }

    public void setWorkPartId(String workPartId) {
        this.workPartId = workPartId;
    }

    public String getWorkPartOrderId() {
        return workPartOrderId;
    }

    public void setWorkPartOrderId(String workPartOrderId) {
        this.workPartOrderId = workPartOrderId;
    }

    public void parseJson(JSONObject jsonObj) throws JSONException {
        if (jsonObj.has("accountId")) {
            setAccountId(jsonObj.getString("accountId"));
        }
        if (jsonObj.has("accountName")) {
            setAccountName(jsonObj.getString("accountName"));
        }
        if (jsonObj.has("applyAmount")) {
            String applyAmountStr = jsonObj.getString("applyAmount");
            if (null != applyAmountStr && !TextUtils.isEmpty(applyAmountStr) && !"null".equals(applyAmountStr)) {
                setApplyAmount(Integer.parseInt(applyAmountStr));
            }
        }
        if (jsonObj.has("applyDays")) {
            String applyDaysStr = jsonObj.getString("applyDays");
            if (null != applyDaysStr && !TextUtils.isEmpty(applyDaysStr) && !"null".equals(applyDaysStr)) {
                setApplyDays(Integer.parseInt(applyDaysStr));
            }
        }
        if (jsonObj.has("completeCount")) {
            String completeCountStr = jsonObj.getString("completeCount");
            if (null != completeCountStr && !TextUtils.isEmpty(completeCountStr) && !"null".equals(completeCountStr)) {
                setCompleteCount(Integer.parseInt(completeCountStr));
            }
        }
        if (jsonObj.has("completeUnusualAccountId")) {
            setCompleteUnusualAccountId(jsonObj.getString("completeUnusualAccountId"));
        }
        if (jsonObj.has("completeUnusualAccountName")) {
            setCompleteUnusualAccountName(jsonObj.getString("completeUnusualAccountName"));
        }
        if (jsonObj.has("completeUnusualDate")) {
            String completeUnusualDateStr = jsonObj.getString("completeUnusualDate");
            if (!TextUtils.isEmpty(completeUnusualDateStr) && !completeUnusualDateStr.equals("null")) {
                setCompleteUnusualDate(Long.parseLong(completeUnusualDateStr));
            }
        }
        if (jsonObj.has("completeUnusualDesc")) {
            setCompleteUnusualDesc(jsonObj.getString("completeUnusualDesc"));
        }
        if (jsonObj.has("confirmCompleteUnusualAccountId")) {
            setConfirmCompleteUnusualAccountId(jsonObj.getString("confirmCompleteUnusualAccountId"));
        }
        if (jsonObj.has("confirmCompleteUnusualAccountName")) {
            setConfirmCompleteUnusualAccountName(jsonObj.getString("confirmCompleteUnusualAccountName"));
        }
        if (jsonObj.has("confirmCompleteUnusualDate")) {
            String confirmCompleteUnusualDateStr = jsonObj.getString("confirmCompleteUnusualDate");
            if (!TextUtils.isEmpty(confirmCompleteUnusualDateStr) && !confirmCompleteUnusualDateStr.equals("null")) {
                setConfirmCompleteUnusualDate(Long.parseLong(confirmCompleteUnusualDateStr));
            }
        }
        if (jsonObj.has("feedbackDate")) {
            String feedbackDateStr = jsonObj.getString("feedbackDate");
            if (!TextUtils.isEmpty(feedbackDateStr) && !feedbackDateStr.equals("null")) {
                setFeedbackDate(Long.parseLong(feedbackDateStr));
            }
        }
        if (jsonObj.has("feedbackInfo")) {
            setFeedbackInfo(jsonObj.getString("feedbackInfo"));
        }
        if (jsonObj.has("feedbackStatus")) {
            CommonEnum.FeedbackStatus feedbackStatus = ParseJson.parseFeedbackStatus(jsonObj, "feedbackStatus");
            setFeedbackStatus(feedbackStatus);
        }
        if (jsonObj.has("handleDate")) {
            String handleDateStr = jsonObj.getString("handleDate");
            if (!TextUtils.isEmpty(handleDateStr) && !handleDateStr.equals("null")) {
                setHandleDate(Long.parseLong(handleDateStr));
            }
        }
        if (jsonObj.has("handleInfo")) {
            setHandleInfo(jsonObj.getString("handleInfo"));
        }
        if (jsonObj.has("handlerAccountId")) {
            setHandlerAccountId(jsonObj.getString("handlerAccountId"));
        }
        if (jsonObj.has("handlerAccountName")) {
            setHandlerAccountName(jsonObj.getString("handlerAccountName"));
        }
        if (jsonObj.has("imgUrlList")) {
            String imgUrlListJsonArrStr = jsonObj.getString("imgUrlList");
            if (null != imgUrlListJsonArrStr && !imgUrlListJsonArrStr.equals("null") && !TextUtils.isEmpty(imgUrlListJsonArrStr)) {
                JSONArray imgUrlListJsonArr = new JSONArray(imgUrlListJsonArrStr);
                ArrayList<String> imgUrlList = new ArrayList<String>();
                for (int s = 0; s < imgUrlListJsonArr.length(); s++) {
                    imgUrlList.add(imgUrlListJsonArr.getString(s));
                }
                setImgUrlList(imgUrlList);
            }
        }
        if (jsonObj.has("subType")) {
            CommonEnum.WorkPartSubType subType = ParseJson.parseSubType(jsonObj, "subType");
            setSubType(subType);
        }
        if (jsonObj.has("type")) {
            CommonEnum.WorkPartType type = ParseJson.parseFeedbackType(jsonObj, "type");
            setType(type);
        }
        if (jsonObj.has("unusualAdvice")) {
            setUnusualAdvice(jsonObj.getString("unusualAdvice"));
        }
        if (jsonObj.has("unusualDays")) {
            String unusualDaysStr = jsonObj.getString("unusualDays");
            if (null != unusualDaysStr && !TextUtils.isEmpty(unusualDaysStr) && !"null".equals(unusualDaysStr)) {
                setUnusualDays(Integer.parseInt(unusualDaysStr));
            }
        }
        if (jsonObj.has("unusualInfo")) {
            setUnusualInfo(jsonObj.getString("unusualInfo"));
        }
        if (jsonObj.has("workPartFeedbackId")) {
            setWorkPartFeedbackId(jsonObj.getString("workPartFeedbackId"));
        }
    }


}
